<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

require_once('src/facebook.php');
	
class Home extends CI_Controller {

	
    function __construct() {

        parent::__construct();
		/*--------------THEMES-----------------------*/
		$this->config->load('themes');
		$theme = $this->config->item('home');
		if($theme == "" || !isset($theme))
			$theme = $this->config->item('global_theme');
			
		$this->data['css_dir'] = base_url()."assets/themes/".$theme."/css/";
		$this->data['js_dir'] = base_url()."assets/themes/".$theme."/js/";	
        $this->data['img_dir'] = base_url()."assets/themes/".$theme."/images/";	
        $this->data['font_dir'] = base_url()."assets/themes/".$theme."/font-awesome-4.1.0/";
        $this->data['module_url'] = base_url().'home/';
		$this->theme = $theme;
		$this->data['logged_in'] = $this->session->userdata('user_logged');
		
		//------------------------------------------------------------------------------
        $this->load->library("email");		
		$this->load->model("google_login");	
		$this->load->model("facebook_login");	
		$this->load->model("user_model");
		$this->data['title'] = "Zpost";
        $this->data['home'] = false;
		
    }
	
	public function index()
	{
        
	    $this->load->view('common/header',$this->data);
        $this->load->view('content',$this->data);
        $this->load->view('common/footer',$this->data);
        
	}
    
    public function preview_email_template()
    {
        $this->data['name'] = "Preview";
        $this->load->view('email_template',$this->data);
    }
    
    public function infographic()
    {
        $this->load->view('common/header',$this->data);
        $this->load->view('infographic',$this->data);
        $this->load->view('common/footer',$this->data);
    }
    
    
    
    public function submit_application()
    {
       
        $post = $this->input->post();
        
        if($this->user_model->email_bullyproof($post))
        {
            
            if($this->user_model->email_bullyproof_notification($post))
            {
                redirect(base_url());
            }
            
        }    
        else
            $this->showError("Error in processing. Email not sent."); 
            
                
    }
    
    public function showError($message)
    {
        $this->data['error_message'] = $message;
        $this->load->view('common/header',$this->data);
        $this->load->view('error',$this->data);
        $this->load->view('common/footer',$this->data); 
        
    }
   
    
    
    
    
   

}

?>
